﻿@{
    ViewBag.Title = "Form";
    Layout = "~/Views/Shared/_Uploader.cshtml";
}
@section Content {
    <script>

        var orderId = $.request("orderId");
        var no = $.request("No");
        var stateType = $.request("StateType");
        var siteAndSpaceId = $.request("siteAndSpaceId");
        

        $(function () {
            $.ajax({
                url: "/OrderFlowManage/ClientOrder/GetToken",
                data: {},
                dataType: "json",
                async: false,
                success: function (data) {
                    //console.log(data);
                    $("#token").val(data.token);
                }
            });

            $.ajax({
                url: "/OrderFlowManage/ClientOrder/GetItemJson?enCode=KPLX",
                data: {},
                dataType: "json",
                async: false,
                success: function (data) {
                    var html = '';
                    for (var i = 0; i < data.length; i++) {
                        var item = data[i];
                        html += '<div class="radio">';
                        html += '   <label>';
                        html += '       <input type="radio" name="optionsRadios" id="optionsRadios' + i + '" value="' + item.Value + '" ' + (i == 0 ? 'checked' : '') + '>';
                        html += item.Text;
                        html += '</label>';
                        html += '</div>';
                    }
                
                    $("#radioPanel").append(html);
                }
                
            });
        });

        function submitForm() {
            var userfile = $("#userfile").val();
            if (userfile) {
                var filePath = $("#userfilepath").val(),
                    fileName = $("#userfilename").val(),
                    fileType = $(".radio input[type='radio'][checked]").val();
                //console.log(radioValue);
                $.submitForm({
                    url: "/OrderFlowManage/ClientOrder/SubmitFileForm?keyValue=" + orderId,
                    param: { orderId: orderId, siteAndSpaceId: siteAndSpaceId, No: no, filePath: filePath, fileName: fileName, fileType: fileType, stateType: stateType },
                    success: function () {
                        $.currentWindow().vm.signcontract.initSignContract();
                        $.loading(false);
                    }
                });
            } else {
                $.modalAlert("请选择你要上传的文件！", "success");
            }
        }
    </script>
}

<div style="padding-top: 20px; margin-right: 20px;">
    <div class="container">
        <!-- Document：https://developer.qiniu.com/kodo/manual/form-upload -->
        <form id="testform" method="post" enctype="multipart/form-data">
            <div class="form-group">
                <label for="userfile">选择合同</label>
                <input name="key" id="key" type="hidden" value="">
                <input id="token" name="token" type="hidden" value="">
                <input id="userfile" name="file" type="file" class="form-control" />
                <input id="userfilepath" name="userfilepath" type="hidden" />
                <input id="userfilename" name="userfilepath" type="hidden" />

                <!-- take photo with phone -->
                <!-- <input id="userfile" name="file" accept="image/*" type="file" /> -->
                <!-- take video with phone -->
                <!-- <input id="userfile" name="file" type="file" accept="video/*"/> -->
                <input name="accept" type="hidden" />
                <p class="help-block">请上传合同文件.</p>
            </div>
            <div id="radioPanel" class="form-group">
                <label for="userfile">合同类型</label>
                @*<div class="radio">
                    <label>
                        <input type="radio" name="optionsRadios" id="optionsRadios1" value="option1" checked>
                        Option one is this and that&mdash;be sure to include why it's great
                    </label>
                </div>
                <div class="radio">
                    <label>
                        <input type="radio" name="optionsRadios" id="optionsRadios2" value="option2">
                        Option two can be something else and selecting it will deselect option one
                    </label>
                </div>*@
            </div>
                

        </form>

        <!-- add file -->
        <label for="userfile">
            <span></span>
            <em>操作说明</em>
        </label>

        <!-- upload info -->
        <div class="selected-file"></div>
        <div class="progress"></div>
        <div class="uploaded-result"></div>
    </div>
</div>


